#pragma once

#include <afx.h>


class CFileHelper
{
public:
	CFileHelper(void);
	~CFileHelper(void);

public:
	BOOL Open(CString path);
	void Close();

	template<typename CallbackT>
	BOOL Read(CallbackT &cb);

	BOOL Write(const char *buff, DWORD &size);

private:
	CFile m_file;
};

template<typename CallbackT>
BOOL CFileHelper::Read(CallbackT &cb)
{
	char buffer[1024];
	DWORD nRead = m_file.Read(buffer, sizeof(buffer));
	while(nRead > 0)
	{
		cb(buffer, nRead);
		nRead = m_file.Read(buffer, sizeof(buffer));
	}
	return TRUE;
}
